package com.exp.bookhouse.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

//@Component   ---没有使用
public class ErrorConfig implements ErrorPageRegistrar {

    /**
     * 集中处理错误页面
     * @param registry
     */
    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
         ErrorPage error403Page = new ErrorPage(HttpStatus.FORBIDDEN, "/error403Page");
         ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/error404Page");
         ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error500Page");
         registry.addErrorPages(error403Page,error404Page,error500Page);
    }
}